//
//  XMSendInviteGiftView.m
//  XunMi
//
//  Created by MacBook on 2024/5/7.
//  Copyright © 2024 TieZhu. All rights reserved.
//

#import "XMSendInviteGiftView.h"
#import "XMInviteMessage.h"

@interface XMSendInviteGiftView ()

@property (weak, nonatomic) IBOutlet UIImageView *imgV;
@property (weak, nonatomic) IBOutlet UIButton *priceLa;
@property (weak, nonatomic) IBOutlet UILabel *nameLa;

@end


@implementation XMSendInviteGiftView

- (void)awakeFromNib {
    [super awakeFromNib];
    [self.priceLa setImagePosition:XMImagePositionLeft spacing:4];
}

- (void)setMessage:(XMInviteMessage *)message {
    _message = message;
    [self.imgV sd_setImageWithURL:kStringToUrl(message.imgUrl) placeholderImage:kDefaultCoverImg];
    [self.priceLa setTitle:kStringFormat(@"%@金币", message.golds) forState:UIControlStateNormal];
    
    NSString *str = kStringFormat(@"对方希望您送她\n%@ x%@", message.name, message.number);
    // 创建NSMutableAttributedString，并设置文本内容和属性
    NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:str];
    // 创建NSMutableParagraphStyle，并设置行高
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    paragraphStyle.alignment = NSTextAlignmentLeft;
    paragraphStyle.lineSpacing = 8; // 设置行高为10个点
    // 将行高属性添加到文本属性中
    [attributedText addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attributedText.length)];
    self.nameLa.attributedText = attributedText;
    [self.nameLa sizeToFit];
}

- (IBAction)closeAct:(UIButton *)sender {
    [self removeFromSuperview];
}

- (IBAction)sendAct:(UIButton *)sender {
    if (self.sendBlock) {
        self.sendBlock(self, self.message);
    }
}


@end
